package com.tjetc;

import lombok.Data;

public class _15Combination {
    public static void main(String[] args) {
        Computer computer = new Computer();
        CPU cpu = new Intel();
        Memory memory = new Kingston();
        computer.setMemory(memory);
        computer.setCpu(cpu);
    }
}

// 使用继承
class Computer1 {
    private Intel intel;
    private Kingston kingston;
}

class Savior extends Computer {
    private Mouse mouse;
}

class Mouse {
    private String name;
}

// 使用组合
@Data
class Computer {
    private CPU cpu;
    private Memory memory;

    public Computer() {
    }

    public Computer(Memory memory, CPU cpu) {
        this.memory = memory;
        this.cpu = cpu;
    }
}


class CPU {
    private String name;
}

class Intel extends CPU {

}

class Memory {
    private int size;
}

class Kingston extends Memory {

}